package com.xing.game.server;

import com.xing.game.bean.DefaultBeanFactory;
import com.xing.game.netty.DefaultWokerFatory;
import com.xing.game.netty.server.NetServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class GameServer {
    private static final Logger logger = LoggerFactory.getLogger(GameServer.class);

    private NetServer netServer;

    public void initSerers(){
        netServer = new NetServer(new DefaultWokerFatory(), 8002).start();
    }

    public void startGame() {
        try {
            long start = System.currentTimeMillis();
            initBeans();
            initSerers();
            long end = System.currentTimeMillis();
            logger.info("启动耗时:{} 毫秒...", end - start);
            logger.info("启动端口:{}", 8002);
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

    public void initBeans() throws Exception{
        DefaultBeanFactory beanFactory = new DefaultBeanFactory();
        beanFactory.registBean(ExcutorWorkers.class);




        new BeanContext(beanFactory);
    }


    public static void main(String[] args) {
        GameServer gameServer = new GameServer();
        gameServer.startGame();
    }
}
